Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-17168] Sync organization user revoked/restored status immediately via push notification #13101

Conversation

r-tome
Copy link
Contributor

@r-tome r-tome commented Jan 28, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-17168

📔 Objective

Revoking/restoring user is not synced immediately via push notification

This PR updates the NotificationsService to handle messages of type NotificationType.SyncOrgKeys by refreshing the identity token.

I also noticed that the SignalR connection stops when receiving a NotificationType.SyncOrgKeys message but does not restart automatically. To fix this, I updated the reconnect method to re-setup the connection.

Server PR.

📸 Screenshots

Revoking and restoring a user a couple of times:

Screen.Recording.2025-01-28.at.12.41.05.mov

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@r-tome r-tome changed the title [PM17168] Sync organization user revoked/restored status immediately via push notification [PM-17168] Sync organization user revoked/restored status immediately via push notification Jan 28, 2025
@r-tome r-tome requested review from a team and BTreston January 28, 2025 12:51
Copy link
Contributor

github-actions bot commented Jan 28, 2025

Logo
Checkmarx One – Scan Summary & Details24a6f130-1359-40da-b0bc-f708778a8eb5

New Issues (1)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
MEDIUM Client_Privacy_Violation /apps/desktop/src/app/tools/password-generator-history.component.html: 15
detailsMethod password_generator_history_component at line 15 of /apps/desktop/src/app/tools/password-generator-history.component.html sends user informat...
Attack Vector
Fixed Issues (1)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
LOW Angular_Usage_of_Unsafe_DOM_Sanitizer /libs/components/src/avatar/avatar.component.ts: 87

Copy link

codecov bot commented Jan 28, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 35.04%. Comparing base (72434bf) to head (57d9548).
Report is 33 commits behind head on main.

Files with missing lines Patch % Lines
...ications/internal/default-notifications.service.ts 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13101      +/-   ##
==========================================
- Coverage   35.41%   35.04%   -0.38%     
==========================================
  Files        3007     3034      +27     
  Lines       90716    92642    +1926     
  Branches    16858    16859       +1     
==========================================
+ Hits        32129    32463     +334     
- Misses      56123    57719    +1596     
+ Partials     2464     2460       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@r-tome r-tome marked this pull request as ready for review January 28, 2025 14:28
@r-tome
Copy link
Contributor Author

r-tome commented Jan 30, 2025

I'm closing this because only the server change is required.

@r-tome r-tome closed this Jan 30, 2025
@r-tome r-tome reopened this Feb 3, 2025
@r-tome r-tome requested a review from a team as a code owner February 3, 2025 14:49
@r-tome
Copy link
Contributor Author

r-tome commented Feb 3, 2025

Reopening this PR — @eliykat explained that we need to refresh the identity token to update the claims.

BTreston
BTreston previously approved these changes Feb 3, 2025
eliykat
eliykat previously approved these changes Feb 3, 2025
@r-tome r-tome dismissed stale reviews from eliykat and BTreston via 1764a8b February 4, 2025 09:33
@r-tome r-tome requested a review from BTreston February 4, 2025 09:33
eliykat
eliykat previously approved these changes Feb 4, 2025
Copy link
Member

@justindbaur justindbaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@justindbaur justindbaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retracting approval for a moment while I think about this behavior on top of how SyncService.fullSync works.

Comment on lines +190 to +193
if (await this.configService.getFeatureFlag(FeatureFlag.PushSyncOrgKeysOnRevokeRestore)) {
// Refresh the identity token to ensure organization roles in JWT claims are up-to-date
await this.apiService.refreshIdentityToken();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually going to keep the rejection only because I think your server change should be enough for now. SyncService.fullSync(true) will automatically call ApiService.refreshIdentityToken(). We are thinking about decoupling that behavior and the change here you have would be right but we are not going to be merging that right now. So please check my assumption here but you should get the desired outcome with only the server PR. I've linked the tickets and mentioned the PR on our decoupling work so that if we go ahead with that we will add the ApiService.refreshIdentityToken call for you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know fullSync already did this for us, so fwiw I'm OK with that suggestion. Thanks @justindbaur

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So please check my assumption here but you should get the desired outcome with only the server PR

Yes that is true, the server PR changes alone are enough. Thanks for looking into this, @justindbaur!

I'll close this PR.

@r-tome
Copy link
Contributor Author

r-tome commented Feb 6, 2025

Closing the PR, see the reason here.

@r-tome r-tome closed this Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants